package com.ecoolex.discount.sales.api.graphql;

import org.apache.dubbo.config.annotation.Reference;
import org.springframework.lang.NonNull;

import com.ecoolex.discount.sales.entity.DiscountBrandWithBLOBs;
import com.ecoolex.discount.sales.entity.MarketingClassifyBrand;
import com.ecoolex.discount.sales.pojo.QueryMarketingClassifyBrandDTO;
import com.ecoolex.discount.sales.ws.DiscountProductService;
import com.ecoolex.discount.sales.ws.MarketingProductService;
import com.ecoolex.framework.common.pojo.Page;
import com.ecoolex.framework.common.pojo.Pagination;
import com.ecoolex.framework.web.api.graphql2.annotation.GraphQL2Module;
import com.ecoolex.framework.web.api.graphql2.annotation.GraphQL2Module.Type;
import com.ecoolex.framework.web.api.graphql2.annotation.QueryField;
import com.ecoolex.framework.web.api.graphql2.annotation.Source;
import com.ecoolex.framework.web.api.graphql2.annotation.TypeField;


@GraphQL2Module(type = Type.User,description = "分类下品牌营销")
public class MarketingClassifyBrandGraphql {
	
	@Reference
	private MarketingProductService marketingProductService;
	
	@Reference
	private DiscountProductService discountProductService;
	
	@TypeField(type = MarketingClassifyBrand.class,field = "discountBrand",description = "折扣品牌")
	public DiscountBrandWithBLOBs discountBrand(@Source MarketingClassifyBrand source) {
		return discountProductService.getDiscountBrand(source.getBrandId());
	}
	
	@QueryField(field = "marketingClassifyBrand",description = "分类下品牌营销详情")
	public MarketingClassifyBrand get(@NonNull Integer id) {
		return marketingProductService.getMarketingClassifyBrand(id);
	}
	
	@QueryField(field = "marketingClassifyBrandList",description = "分类下品牌营销列表")
	public Pagination<MarketingClassifyBrand> query(@NonNull QueryMarketingClassifyBrandDTO query,@NonNull Page page){
		return marketingProductService.queryMarketingClassifyBrandForH5(query, page);
	}
}
